package com.shiminghui;

import java.util.Random;

public class QiangHongBao {
    public static void main(String[] args) {
        Random random = new Random();
        int[] arr = {2,588,888,1000,10000};
        int[] flag = new int[arr.length];
        for (int i = 0; i < flag.length; i++) {
            flag[i]=0;
        }
        int length = arr.length;
        while (length!=0){
            int index=random.nextInt(arr.length);
            if (flag[index]==0){
                System.out.println(arr[index]+"奖金已抛出");
                flag[index]=1;
                length--;
            }

        }


        //另一个思路,打乱顺序
        for (int i = 0; i < arr.length; i++) {
            int index=random.nextInt(arr.length);
            int temp=arr[i];
            arr[i]=arr[index];
            arr[index]=temp;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }



    }
}
